﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    /// <summary>
    /// 事件
    /// </summary>
    public class EventDemo
    {
        //第一步:声明委托
        public delegate void DelegateDisaster(string classRom);

        //第二步:声明事件
        public event DelegateDisaster EventDisaster;

        /// <summary>
        /// 发生事件，执行事件
        /// </summary>
        public void Do() {
            //第三步：为委托绑定处理的方法
            EventDisaster += new DelegateDisaster((classRom) => {
                Console.WriteLine("地震灾害发生。。。");
            });
            EventDisaster += new DelegateDisaster((classRom) => {
                Console.WriteLine("正在停止上课，出教室避难");
            });
            EventDisaster += new DelegateDisaster((classRom) => {
                Console.WriteLine("班主任引导学生走楼梯到1楼！");
            });
            EventDisaster += new DelegateDisaster((classRom) => {
                Console.WriteLine("学校安全管理员指挥避难！");
            });
            EventDisaster += new DelegateDisaster((classRom) => {
                Console.WriteLine("灾害发生，天塌地陷!");
            });
            EventDisaster("T310");
        }
    }
}
